package com.cloud.service;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.cloud.core.BaseService;
import com.cloud.dao.DoctorBean;
import com.cloud.dao.DoctorInfo;
import com.cloud.dao.HospitalBean;
import com.cloud.dao.InvestigatorsBean;
import com.cloud.dao.PatientBean;
import com.cloud.dao.ProjectBean;
import com.cloud.dao.impl.DoctorDao;
import com.cloud.util.CommUtil;

/**
 * 1Cloud1
 * @author Administrator
 * @since 2015-12-4
 * @version 1.0 
 */
@Service("DoctorService")
public class DoctorService extends BaseService{
	private static final Logger logger = LoggerFactory.getLogger(DoctorService.class);
	@Value("${cloud.doctor.random}")
	public String drandom;
	
	@Autowired
	private DoctorDao DoctorDao;
	
	public List<DoctorInfo> queryDoctorContact(DoctorBean bean){
		return DoctorDao.queryDoctorContact(bean);
	}
	
	public List<String> queryRandomDoctorIdList(DoctorBean bean){
		List<String> doctorIdList = queryDoctorIdList(bean);
		if(doctorIdList == null || doctorIdList.size() == 0)
			return null;
		return CommUtil.getRandomNum(doctorIdList, Integer.valueOf(getDrandom()));
	}
	
	private List<String> queryDoctorIdList(DoctorBean bean){
		return DoctorDao.queryDoctorIdList(bean);
	}
	
	public List<DoctorInfo> queryDoctor(DoctorBean bean){
		return DoctorDao.queryDoctor(bean);
	}
	
	public List<DoctorBean> getDoctorList(DoctorBean bean){
		logger.debug(String.format("开始查询医生[%s]的信息.", bean.getId()));
		return DoctorDao.getDoctorList(bean);
	}
	
	public void addDoctor(DoctorBean bean){
		DoctorDao.addDoctor(bean);
	}
	
	public void updateDoctor(DoctorBean bean){
		DoctorDao.updateDoctor(bean);
	}
	
	public void deleteDoctor(DoctorBean bean){
		DoctorDao.deleteDoctor(bean);
	}

	public String getDrandom() {
		return drandom;
	}

	public void setDrandom(String drandom) {
		this.drandom = drandom;
	}
	
	public List<ProjectBean> queryProjectByPatient(PatientBean bean){
		return DoctorDao.queryProjectByPatient(bean);
	}
	
	public List<ProjectBean> queryProjectByDoctor(DoctorBean bean){
		return DoctorDao.queryProjectByDoctor(bean);
	}
	
	public List<HospitalBean> queryHospitalByPro(String pro_id){
		return DoctorDao.queryHospitalByPro(pro_id);
	}
	
	public List<DoctorBean> queryDoctorByProHos(InvestigatorsBean bean){
		return DoctorDao.queryDoctorByProHos(bean);
	}
	
	public List<PatientBean> queryPatientByProHos(InvestigatorsBean bean){
		return DoctorDao.queryPatientByProHos(bean);
	}
	
	public String queryCrcByDoctorProject(InvestigatorsBean bean){
		return DoctorDao.queryCrcByDoctorProject(bean);
	}
}
